<?php
declare(strict_types=1);

namespace App\Models\Admin\Image;


use App\Models\Admin\User\Author;
use App\Models\Admin\User\User;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasOne;

class ImageItem extends \App\Models\Image\ImageItem
{
    protected $appends = [
        "cover"
    ];

    public function image(): BelongsTo
    {
        return $this->belongsTo(Image::class, "image_uid", "uid");
    }

    public function getCoverAttribute($key): string
    {
        return $this->getAttribute("url") . $this->getAttribute("path");
    }

    public function user(): HasOne
    {
        return $this->hasOne(User::class, "uid", "user_uid");
    }

    public function author(): HasOne
    {
        return $this->hasOne(Author::class, "uid", "author_uid");
    }
}
